#include "interface_settings.hpp"
#include "face_detect_algo.hpp"
#include <fstream>

std::string InterfaceSettings::Get_weight_file() const
{
  return this->weight_file_;
}

void InterfaceSettings::Set_weight_file(const std::string &newWeight_file)
{
  this->weight_file_ = newWeight_file;
}

std::string InterfaceSettings::Get_config_file() const
{
  return this->config_file_;
}

void InterfaceSettings::Set_config_file(const std::string &newConfig_file)
{
  this->config_file_ = newConfig_file;
}

float InterfaceSettings::Get_t_score() const
{
  return this->t_score_;
}

void InterfaceSettings::Set_t_score(float newT_score)
{
  this->t_score_ = newT_score;
}

bool InterfaceSettings::Get_show_fps() const
{
  return this->show_fps_;
}

void InterfaceSettings::Set_show_fps(bool newShow_fps)
{
  this->show_fps_ = newShow_fps;
}

bool InterfaceSettings::Get_show_score() const
{
  return this->show_score_;
}

void InterfaceSettings::Set_show_score(bool newShow_score)
{
  this->show_score_ = newShow_score;
}

std::string InterfaceSettings::Get_data_path() const
{
  return this->data_path_;
}

void InterfaceSettings::Set_data_path(const std::string &newData_path)
{
  this->data_path_ = newData_path;
}

void InterfaceSettings::Load_settings()
{
  cv::FileStorage fs("face_detector_settings.yaml", cv::FileStorage::READ);
  if (!fs.isOpened())
  {
    std::cout << "Could not open the file face_detector_settings.yaml" << std::endl;
    return;
  }
  fs["weight_file"] >> this->weight_file_;
  fs["config_file"] >> this->config_file_;
  fs["t_score"] >> this->t_score_;
  fs["show_fps"] >> this->show_fps_;
  fs["show_score"] >> this->show_score_;
  fs["data_path"] >> this->data_path_;
  fs.release();
}

void InterfaceSettings::Dump_settings()
{
  cv::FileStorage fs("face_detector_settings.yaml", cv::FileStorage::WRITE);
  if (!fs.isOpened())
  {
    std::cout << "Could not open the file face_detector_settings.yaml" << std::endl;
    return;
  }
  fs << "weight_file" << this->weight_file_;
  fs << "config_file" << this->config_file_;
  fs << "t_score" << this->t_score_;
  fs << "show_fps" << this->show_fps_;
  fs << "show_score" << this->show_score_;
  fs << "data_path" << this->data_path_;
  fs.release();
}
